package input;

import com.jme.input.controls.GameControl;
import com.jme.input.controls.binding.MouseAxisBinding;
import com.jme.input.controls.binding.MouseButtonBinding;
import com.jme.scene.Node;
import com.jme.system.DisplaySystem;

/**
 * Super-class for the {@link Player}s mouse-input. Only sets up the bindings for the left and the 
 * right mouse-button.
 * 
 * @author Wasserleiche
 */
public abstract class PlayerMouseInput extends NodeInputHandler {
	
	protected final float MAX_DOUBLE_CLICK_TIME = 0.2f;
	
	protected GameControl leftButton, middleButton, rightButton, mouseWheelDown, mouseWheelUp;
	/** The {@link Mouse} that will e used.b */
	/** Indicates weather the mouse is enabled or not. */
	protected boolean mouseEnabled;
	protected DisplaySystem display;
	
	/**
	 * Constructs a new PlayerMouseInput-Object, fetches the mouse from the current {@link IngameState} and 
	 * initializes the mouse-button-bindings.
	 * @param rootNode The root-Node that will be used.
	 */
	public PlayerMouseInput(Node rootNode) {
		super(rootNode);
		display = DisplaySystem.getDisplaySystem();
		
		setMouseBindings();
	}
	/**
	 * Initializes the bindings for the left and the right mouse-button.
	 */
	protected void setMouseBindings() {
		rightButton = manager.addControl("Right Button Pushed");
		rightButton.addBinding(new MouseButtonBinding(MouseButtonBinding.RIGHT_BUTTON));
		leftButton = manager.addControl("Left Button Pushed");
		leftButton.addBinding(new MouseButtonBinding(MouseButtonBinding.LEFT_BUTTON));
		middleButton = manager.addControl("Middle Button Pushed");
		middleButton.addBinding(new MouseButtonBinding(MouseButtonBinding.MIDDLE_BUTTON));
		
		mouseWheelUp = manager.addControl("Mouse Wheel Up");
		mouseWheelUp.addBinding(new MouseAxisBinding(MouseAxisBinding.AXIS_W, false));
		mouseWheelDown = manager.addControl("Mouse Wheel Down");
		mouseWheelDown.addBinding(new MouseAxisBinding(MouseAxisBinding.AXIS_W, true));
	}
	
	/**
	 * Returns weather the mouse is enabled or not.
	 * @return true, if the mouse is enabled. false, if not.
	 */
	public boolean mouseEnabled() { return mouseEnabled; }
}